package org.yjc.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.KingRoot;
import org.yjc.repository.KingRootRepository;

@Service
public class KingRootService {
	@Autowired
	private KingRootRepository kingrootDAO;

	public Page<KingRoot> findAll(Pageable pageable) {
		return kingrootDAO.findAll(pageable);
	}

	public Page<KingRoot> findAll(Specification spec, Pageable pageable) {
		return kingrootDAO.findAll(spec, pageable);
	}

	public void deleteById(int parseInt) {
		kingrootDAO.deleteById(parseInt);
	}

	public void save(KingRoot kingroot) {
		kingrootDAO.save(kingroot);
		
	}

	public KingRoot findById(int parseInt) {
		Optional<KingRoot> optional = kingrootDAO.findById(parseInt);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}
}
